linestring 0.2.0

2d and 3d polylines
Documentation

Crates.io Documentation Workflow Workflow dependency status

Line library for Rust

This crate contains data structures and methods that deals with lines in 2D and 3D space.

There are 3D and 2D implementations of:

There are 2D implementations of:

  • LineString2 convex hull calculation (gift wrapping & Graham scan)
  • Aabb axis aligned bounding box.
  • Self intersection tests for line strings, or groups of lines O( n log n + i log n).
  • Convex hull containment test (single threaded or multi-threaded with ryon)
  • Simple affine transformation (pan, zoom)

This is implemented for cgmath, nalgebra, vecmath and limited versions for mint and plain vectors (no matrix transformations).
These implementations are feature gated, so you only have to include the 3d package you need in your code. More implementations could be added if required.

If you want to use this library in your cgmath project you add this to your Cargo.toml:

linestring = {version="^0.2.0",default-features=false,features=["impl-cgmath", "impl-rayon"]}

Same thing for the other supported 2d/3d libraries:

linestring = {version="^0.2.0",default-features=false,features=["impl-nalgebra", "impl-rayon"]}
linestring = {version="^0.2.0",default-features=false,features=["impl-mint", "impl-rayon"]}
linestring = {version="^0.2.0",default-features=false,features=["impl-vecmath", "impl-rayon"]}
linestring = {version="^0.2.0",default-features=false,features=["impl-vec", "impl-rayon"]}

The difference between impl-vecmath and impl-vec is that the impl-vecmath feature supports matrix transformations.

Demo GUI

Run the line simplification example with :

cargo run --example fltk_gui --no-default-features --features impl-cgmath,impl-rayon

Todo

  • Improve on error handling
  • Benchmark and optimize (add smallvec to simplify rdp?)
  • optimize Ramer–Douglas-Peucker
  • optimize Visvalingam-Whyatt
  • Add 2D Convex hull and containment test
  • multi-threaded Convex hull containment test
  • Stable overlapping co-linear line detection
  • Better event handling in fltk_gui